package com.zking.frame.TJ.JDBC;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class JDBC_Test {
	 private static final String url = "jdbc:mysql://localhost:3306/lyk?characterEncoding=utf-8";
	 public static final String user = "root";
	 public static final String password = "1693397925liu";
	 public static final String driver = "//////com.mysql.jdbc.Driver";
	 
	//获取jdbc的连接
	public  Connection getConnection() {
		Connection conn = null;
		try {
			conn = DriverManager.getConnection(url, user, password);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
	
	public void closeResource(Connection conn, Statement st, ResultSet rs) {
		try {
			if (conn != null) {
				conn.close();
			}
			if (st != null) {
				st.close();
			}
			if (rs != null) {
				rs.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	//释放资源
	public void closeResource(Connection conn, Statement st) {
		try {
			if (conn != null) {
				conn.close();
			}
			if (st != null) {
				st.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		JDBC_Test jdbc_test = new JDBC_Test();
		System.out.println(jdbc_test.getConnection());
	}
}
